//
//  StatisticLoadingView.m
//  soosoa
//
//  Created by WangJianbang on 2016/11/16.
//  Copyright © 2016年 liq. All rights reserved.
//

#import "StatisticLoadingView.h"
#import "CommonHeader.h"

@interface StatisticLoadingView()

@property(nonatomic,strong)NSMutableArray *imgArray;

@end

static StatisticLoadingView *_ldView = nil;
@implementation StatisticLoadingView

-(id)initWithFrame:(CGRect)frame imgArr:(NSMutableArray*)arr{
    self = [super initWithFrame:frame];
    if(self){
        self.imgArray=arr;
        self.backgroundColor = [UIColor whiteColor];
        [self initData];
        [self createMain];
    }
    return self;
}
-(void)initData{
    if (_imgArray.count==0) {
        _imgArray = [NSMutableArray array];
        for (int i = 0; i<3; i++) {
            UIImage *img = [UIImage imageNamed:[NSString stringWithFormat:@"laod_%d",i]];
            if(!img) continue;
            [_imgArray addObject:img];
        }
    }
   
}
-(void)createMain{
    self.animatImgView = [[UIImageView alloc]init];
    
    self.animatImgView.animationImages = self.imgArray;
    self.animatImgView.animationDuration = 1.7;
    [self addSubview:self.animatImgView];
    [self.animatImgView performSelector:@selector(startAnimating) withObject:nil afterDelay:0 inModes:@[NSRunLoopCommonModes]];

    [self.animatImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.mas_centerX);
        make.centerY.equalTo(self.mas_centerY).offset(-adaptHeight1334(42+26));
    }];
    
    UILabel *lab1 = [UILabel new];
    self.contentLB = lab1;
    lab1.text = @"正在加载中，请稍等~";
    lab1.font = [UIFont systemFontOfSize:adaptFontSize(26)];
    lab1.textColor = [UIColor jk_colorWithHexString:@"#a3a3a3"];
    [self addSubview:lab1];
    [lab1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.animatImgView.mas_bottom).with.offset(adaptHeight1334(42));
        make.centerX.mas_equalTo(self);
    }];
}


@end
